package org.paic.d.test

import org.paic.d.Dialect

class DialectTest extends GroovyTestCase {

	void testSetLimitSupport() {
		def d = new Dialect()

		d.limitSupport = true
		assert d.limitSupport

		d.limitSupport = false
		assert !d.limitSupport
	}

	void testGetPagiSql(){
		def d = new Dialect()
		d.limitSupport = false

		String sql = 'select * from t1'
		assert "select * from (select xxx.*, rownum as rrr from (${sql}) xxx) ttt where ttt.rrr > 100 and ttt.rrr <= 110" == 
			d.getPagiSql(sql, 100, 10)

		d.limitSupport = true
		assert "select ttt.* from (${sql}) ttt limit 100,10" == 
			d.getPagiSql(sql, 100, 10)
	}

	void testGetCountSql(){
		String sql = 'select * from t1'

		def d = new Dialect()
		
		assert "select count(*) as NUMS from (${sql}) ttt" == d.getCountSql(sql)
	}

}